package com.app.auth.controller;

import com.app.auth.entity.RoleInfo;
import com.app.auth.entity.User;
import com.app.auth.entity.UserInfo;
import com.app.auth.enums.Events;
import com.app.auth.service.HomeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/")
public class HomeController {

    @Autowired
    private HomeService homeService;

    @GetMapping("/hello/{name}")
    @ApiOperation(value = "hello world")
    public String hello(@PathVariable String name) {
        return "hello " + name;
    }

    @PostMapping("/user")
    public Integer user(@RequestBody UserInfo userInfo) {
        return homeService.userInfo(userInfo);
    }

    @GetMapping("/user")
    public List<UserInfo> user() {
        return homeService.userInfos();
    }

    @GetMapping("/role")
    public List<RoleInfo> role() {
        return homeService.roleInfos();
    }

    @PostMapping("/userInfo")
    public Integer user(@RequestBody User userInfo) {
        return homeService.user(userInfo);
    }

    @GetMapping("/stateMachine/{event}")
    public void stateMachine(@PathVariable int event) {
//        Events.
         homeService.stateMachine(Events.PAY);
    }

}
